package com.example.exam.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.exam.entity.Topic;
import com.example.exam.entity.VO.QuestionVo;
import com.example.exam.entity.VO.TopicList;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;

/**
 * @author zhang
 */
@Mapper
public interface QuestionMapper extends BaseMapper<Topic> {
    @Select("select * from question_bank where id = #{id}")
    QuestionVo selectVoById(@Param(value = "id") Integer id);

    @Select("select option_img.url as op form option_img inner join question_img.url as cp where id = {#id}")
    QuestionVo questionVo(@Param(value = "id") Integer id);

    /*
     * 查询题目列表 id content type
     */
    @Select("select id, content, type from question_bank where status = 1")
    IPage<TopicList> selectQuestionList(Page<?> page);
}
